<template>
	<scroll-view class="proview" :scroll-y="true">
		<up-loading-page :loading="loading" bg-color="#e8e8e8" loading-text="加载中..."></up-loading-page>
		<image  :src="imgSrc" mode="widthFix" class="image"></image>
	</scroll-view>
</template>

<script setup>
	import {
		previewMonthly,
		previewYearly
	} from "@/api/proview.js"
	import {
		onLoad,
	} from '@dcloudio/uni-app'
	import {
		ref,
		reactive,
	} from 'vue'
	import config from '/config.js'
	const planId = ref('')
	const imgSrc = ref("")
	const loading = ref(false)
	
	onLoad(option => {
		console.log(option,'option');
		planId.value = option.id
		if(option.type == '年检') {
			getYearImg()
		} else {
			getMonthImg()
		}
	})
	
	// 获取月检任务
	const getMonthImg = () => {
		loading.value = true
		previewMonthly(planId.value).then(res => {
			loading.value = false
			getData(res)
		})
	}
	// 获取年检任务
	const getYearImg = () => {
		loading.value = true
		previewYearly(planId.value).then(res => {
			loading.value = false
			getData(res)
		})
	}
	const getData= res => {
		if(res.code == 200) {
			imgSrc.value = res.msg
		} 
	}
</script>

<style lang="less" scoped>
	@import "../../App.less";
	.proview {
		width: 100%;
		height: 100%;
		// overflow: hidden;
		.image {
			width: 100%;
			height: 100%;
		}
	}
</style>